import {configureStore, getDefaultMiddleware} from "@reduxjs/toolkit";
import {actionLog} from "./middlewares/log";
import {articleSlice, recommendSlice, topicSlice, trendingSlice, writerSlice} from "./slices";
import {showScrollSlice} from "./slices/common";
import {throttleMiddleware} from "./middlewares/throttle";
import {show, hide} from './slices'

const throttle = throttleMiddleware([show.type, hide.type])

const store = configureStore({
  reducer: {
    trending: trendingSlice.reducer,  // 热搜
    topic: topicSlice.reducer,  // 主题
    recommend: recommendSlice.reducer, // 推荐
    article: articleSlice.reducer, // 文章
    writer: writerSlice.reducer,  // 作者
    showScroll: showScrollSlice.reducer
  },
  middleware: [...getDefaultMiddleware(), throttle, actionLog]
})

export default store;

export type RootState = ReturnType<typeof store.getState>;
